package com.newsnetwork.exception;

import com.newsnetwork.grace.result.ResponseStatusEnum;

/**
 * @author DingNing
 * @date 2022/11/4 15:53
 * @Description: 自定义异常
 *           目的： 统一处理异常
 *                 便于解耦，service与controller错误的解耦，不会被service返回的类型而限制
 */
public class MyCustomException extends RuntimeException{
    private ResponseStatusEnum responseStatusEnum;
    public MyCustomException(ResponseStatusEnum responseStatusEnum) {
        super("异常状态码为：" + responseStatusEnum.status()
                + "；具体异常信息为：" + responseStatusEnum.msg());
        this.responseStatusEnum = responseStatusEnum;
    }


    public ResponseStatusEnum getResponseStatusEnum() {
        return responseStatusEnum;
    }

    public void setResponseStatusEnum(ResponseStatusEnum responseStatusEnum) {
        this.responseStatusEnum = responseStatusEnum;
    }
}
